package com.cn.zpark;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Arrays;

/**
 * @PackageName: com.cn.zpark
 * @ClassName: RequestDemo03
 * @Description:
 * @author: RZS
 * @date: 2022/4/12  20:01
 */
@WebServlet("/req3.do")
public class RequestDemo03 extends HttpServlet {
    @Override
    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // 解决post请求乱码
        // 设置请求缓冲区字符编码
        request.setCharacterEncoding("utf-8");

        // 获取用户提交的数据, 参数的值就是对应标签的name属性的值
        String username = request.getParameter("username");
        System.out.println(username);
        String password = request.getParameter("password");
        System.out.println(password);
        String sex = request.getParameter("sex");
        System.out.println(sex);
        String[] languages = request.getParameterValues("language");
        System.out.println(Arrays.toString(languages));
        String city = request.getParameter("city");
        System.out.println(city);

    }
}
